home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
ARASAN_S.ZIP
/
SORTMOVE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-22
|
790b
|
44 lines
// Copyright 1992 by Jon Dart. All Rights Reserved.
#include "moveord.h"
// We put this function in a separate file because it is the only
// part of Move_Ordering that the "makebook" program needs.
void Move_Ordering::sort_moves(Move moves[], int scores[], int n)
{
// uses Shell sort
int gap, i, j, tj, tc;
Move t;
gap = n / 2;
while (gap)
{
for (i = gap; i < n; i++)
{
j = i - gap;
while (j >= 0)
{
tj = j + gap;
if (scores[j] < scores[tj])
{
t = moves[j];
moves[j] = moves[tj];
moves[tj] = t;
tc = scores[j];
scores[j] = scores[tj];
scores[tj] = tc;
} else
break;
if (j >= gap)
j -= gap;
else
break;
}
}
gap /= 2;
}
}